<%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
import="javazoom.upload.*,java.util.Hashtable,Application.Dao.MainCourseDAO,DomainData.MainCourse"
    pageEncoding="ISO-8859-1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link href="css/general.css" rel="stylesheet" type="text/css" />
</head>
<jsp:useBean id="upBean" scope="page" class="javazoom.upload.UploadBean" >
  <jsp:setProperty name="upBean" property="folderstore" value="C:\apache-tomcat-6.0.32-windows-x86\webapps\ReservationSystem\images" />
</jsp:useBean>
<%
String name="";
String description="";
String priceStr="";
double price=0.0;
	/* String name=request.getParameter("title");
	String description= request.getParameter("description");
	String priceStr=request.getParameter("price");
	double price=0.0;
	if(priceStr!=null&&!priceStr.equals(""))
		price= Double.parseDouble(priceStr);
	MainCourse mainCourse=new MainCourse(name,description,price);
	MainCourseDAO.insertMainCourse(mainCourse); */
	
%>
<%
if (MultipartFormDataRequest.isMultipartFormData(request))
{
   // Uses MultipartFormDataRequest to parse the HTTP request.
   MultipartFormDataRequest mrequest = new MultipartFormDataRequest(request);
   String todo = null;
   if (mrequest != null) todo = mrequest.getParameter("todo");
   if ( (todo != null) && (todo.equalsIgnoreCase("upload")) )
   {
          Hashtable files = mrequest.getFiles();
          if ( (files != null) && (!files.isEmpty()) )
          {
              UploadFile file = (UploadFile) files.get("uploadfile");
              if (file != null) System.out.println("<li>Form field : uploadfile"+"<BR> Uploaded file : "+file.getFileName()+" ("+file.getFileSize()+" bytes)"+"<BR> Content Type : "+file.getContentType());
              // Uses the bean now to store specified by jsp:setProperty at the top.
              upBean.store(mrequest, "uploadfile");
              System.out.println("Success");
              
              
              //
            name=mrequest.getParameter("title");
            description	= mrequest.getParameter("description");
            priceStr=mrequest.getParameter("price");
            	
            	if(priceStr!=null&&!priceStr.equals(""))
            		price= Double.parseDouble(priceStr);
            	MainCourse mainCourse=new MainCourse(name,description,price);
            	MainCourseDAO.insertMainCourse(mainCourse);
          }
          
          else
          {
            System.out.println("<li>No uploaded files");
          }
   }
   else out.println("<BR> todo="+todo);
}
%>
<body>
	<div class="mainBackground"></div>
	<div id="maincontent" class="center">
		<h2>This is the new main course you just entered.</h2>
		<table>
			<tr>
				<td>Name:<%=name%> </td>
			</tr>
			<tr>
				<td>Description:<%=description%> </td>
			</tr>
			<tr>
				<td>Price: <%=price%> </td>
			</tr>
		</table>
		<img src="images/imagesample2.jpg" width="250" height="150" alt="imag" class="leftalign" />
		
		
			
			
	</div>
	<div class="clear"></div>
	
	<div id="footer">
		&copy; K&G Restaurant | all Rights Reserved by CSE 333 <span
			class="credit"><a
			href="http://www.weibo.com/gaotaojie/profile?topnav=1&wvr=4">Taojie
				Gao's Paradise</a> by Taojie Gao</span>

	</div>
</body>
</html>